<?php
# User session management
require_once('includes/user_manage.php');

	$user->email=htmlentities($_POST["user_name"]);
	$user->password=htmlentities($_POST["user_password"]);
	if ($user->login()) {
		$user->db_load();
		$_SESSION["ser_user"]=serialize($user);
		if (isset($_POST["serOrder"]) && $_POST["serOrder"]) include($server->get_path_name('check_out_1.php'));
		else include($server->get_path_name('user_area.php'));
?>
<script type="text/javascript">
// The user es connected so the user status section must be updated with this status
document.getElementById("connectButtonBox").className = "connected";
document.getElementById("connectButton").innerHTML = "Conectado";
document.getElementById("connectStatusName").innerHTML = "<?php echo $user->firstname." ".$user->lastname ?>";
document.getElementById("disconnectText").innerHTML = "Desconectar";
document.getElementById("disconnectLink").href = "?section=disconnect";
<?php
if ($user->isAdmin) { 
?>
	location.reload();
<?php
}
?>
</script>
<?php
	}
	else {
?>
<div class="note">
	El nombre de usuario o contraseña no coinciden con ningún usuario por favor vuelve a introducir tus datos.
</div>

<?php
		include($server->get_path_name('login.php'));
	}
?>
